let addressBookList = [
  {
    id: 1,
    name: "张三丰",
  },
  {
    id: 2,
    name: "张无忌",
  },
  {
    id: 3,
    name: "周芷若",
  },
  {
    id: 4,
    name: "李易峰",
  },
  {
    id: 5,
    name: "胡歌",
  },
  {
    id: 6,
    name: "艾琳",
  },
  {
    id: 7,
    name: "杨林",
  },
];
const pinyin = require("js-pinyin");

addressBookList.map((item) => {
  item.letter = pinyin.getFullChars(item.name).charAt(0);
});
addressBookList.sort((a, b) => a.name.localeCompare(b.name));

//获取排序后的数据
console.log(addressBookList);
